package com.koron.configure.workflow.bean.dto;

import com.koron.common.core.util.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

/**
 * @author jzp
 * @since 2022/1/12
 */
@Data
public class ConfigureWorkflowNodeDTO {
    @ApiModelProperty("节点id")
    private String nodeId;

    @ApiModelProperty("节点编码")
    private String nodeCode;

    @ApiModelProperty("节点名称")
    private String nodeName;

    @ApiModelProperty("插件列表")
    private List<ConfigureWorkflowPluginDTO> configureWorkflowPluginDTOList;

    /**
     * 获取当前节点有效插件数量
     */
    public long getPluginSize() {
        if (!CollectionUtils.isEmpty(this.configureWorkflowPluginDTOList)) {
            return this.configureWorkflowPluginDTOList.stream().filter(e -> !StringUtils.isEmpty(e.getAccessUrl())).count();
        }
        return 0;
    }
}
